#!/usr/bin/env python
# encoding: utf-8
"""
middleware.py

Created by reedhong on 2011-10-17.
Copyright (c) 2011 __MyCompanyName__. All rights reserved.
"""

from django.conf import settings

class VersionMiddleware(object):
    def process_request(self, request):
        user_agent = request.META.get("HTTP_USER_AGENT", None)
        if user_agent.startswith(settings.CLIENT_AGENT_PREFIX):
            request.is_client = True
            request.client_version = user_agent[len(settings.CLIENT_AGENT_PREFIX):]
        else:
            request.is_client = False



